// pages/consult/djzx/djzx.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    show:false,
    onClose3:false,
    activeKey: 0,
    tags: [
      {id: 1, name: '全部', selected: false},
      {id: 2, name: '个人成长', selected: false},
      {id: 3, name: '恋爱关系', selected: false},
      {id: 4, name: '婚姻家庭', selected: false},
      {id: 5, name: '亲子教育', selected: false},
      {id: 6, name: '职场心理', selected: false},
      {id: 7, name: '两性心理', selected: false},
      {id: 8, name: '抑郁疏导', selected: false},
      {id: 9, name: '情绪管理', selected: false},
      {id: 10, name: '人际关系', selected: false},
      {id: 11, name: '心理健康', selected: false},
      {id: 12, name: '婆媳矛盾', selected: false}
    ],
    maxSelect: 3,
    selectedCount: 0,
    tags3: [
      {id: 1, name: '男', selected: true},
      {id: 2, name: '女', selected: false},
      {id: 3, name: '不限', selected: false}
    ],
    maxSelect3: 1,
    selectedCount3: 1,
    tagszxfs: [
      {id: 1, name: '视频咨询', selected: true},
      {id: 2, name: '语言咨询', selected: false},
      {id: 3, name: '倾述咨询', selected: false}
    ],
    maxSelectzxfs: 1,
    selectedCountzxfs: 1,
  },

  selectTag: function (e) {
    const index = e.currentTarget.dataset.index;
    const { tags, selectedCount, maxSelect } = this.data;
    const tag = tags[index];
    

    if (tag.selected) {
      // 取消选中
      tag.selected = false;
      this.setData({
        ['tags[' + index + '].selected']: false,
        selectedCount: selectedCount - 1
      });
    } else {
      if (selectedCount < maxSelect) {
        // 选中
        tag.selected = true;
        this.setData({
          ['tags[' + index + '].selected']: true,
          selectedCount: selectedCount + 1
        });
      } else {
        // 超出限制提示
        wx.showToast({
          title: '最多只能选3个标签',
          icon: 'none'
        });
      }
    }
  },
  selectTag3: function (e) {
    const index = e.currentTarget.dataset.index;
    const { tags3, selectedCount3, maxSelect3 } = this.data;
    const tag3 = tags3[index];

    if (tag3.selected) { 
      // 取消选中
      tag3.selected = false;
      this.setData({
        ['tags3[' + index+ '].selected']: false,
        selectedCount3: selectedCount3 - 1
      });
    } else {
      if (selectedCount3 < maxSelect3) {
        // 选中
        tag3.selected = true;
        this.setData({
          ['tags3[' + index + '].selected']: true,
          selectedCount3: selectedCount3 + 1
        });
      } else {
        // 超出限制提示
        wx.showToast({
          title: '最多只能选1个标签',
          icon: 'none'
        });
      }
    }
  },
  //咨询方式
  selectzxfs: function (e) {
    const index = e.currentTarget.dataset.index;
    const { tagszxfs, selectedCountzxfs, maxSelectzxfs } = this.data;
    const tagzxfs = tagszxfs[index];

    if (tagzxfs.selected) { 
      // 取消选中
      tagzxfs.selected = false;
      this.setData({
        ['tagszxfs[' + index+ '].selected']: false,
        selectedCountzxfs: selectedCountzxfs - 1
      });
    } else {
      if (selectedCountzxfs < maxSelectzxfs) {
        // 选中
        tagzxfs.selected = true;
        this.setData({
          ['tagszxfs[' + index + '].selected']: true,
          selectedCountzxfs: selectedCountzxfs + 1
        });
      } else {
        // 超出限制提示
        wx.showToast({
          title: '最多只能选1个标签',
          icon: 'none'
        });
      }
    }
  },





  showPopup1() {
    this.setData({ show1: true });
  },showPopup2() {
    this.setData({ show2: true });
  },showPopup3:function(){
    this.setData({
      onClose3: true
    })
  },showPopup4:function(){
    this.setData({
      onClose3: false
    })
  },

  onClose1() {
    this.setData({ show1: false });
  },  onClose2() {
    this.setData({ show2: false });
  },
    // 点击确定以后去的页面
    gotodjqd() {
        wx.navigateTo({
          url: '/pages/index/consultyy/consultsuccess/consultsuccess',
        })
      },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})